/* 
* @Author: Marte
* @Date:   2017-01-12 15:04:33
* @Last Modified by:   Marte
<<<<<<< HEAD
* @Last Modified time: 2017-01-16 17:49:36
=======
* @Last Modified time: 2017-01-17 09:42:49
>>>>>>> bec7a032673b8195ffab065664db93dcb8254e41
*/

angular.module("myKitchen")
.controller("mineMyGroupController",["$scope","mineMyGroupService",function($scope,mineMyGroupService){
        mineMyGroupService.getItems1(function(res){
            // console.log(res)
        $scope.myGroupItems = res.data.items
            // console.log($scope.myGroupItems[1])
        })
        $scope.getItems=function(item){
            $scope.itemd=item;
        }

}])
.controller("myOrderController",["$scope","classifyService",function($scope,classifyService){

   /* $scope.showBorder = function(index){
          $scope.border = [];
        $scope.border[index] ="showBorder";
    }*/
   /* $scope.showOrder= function(){
        $scope.bol=false;
      return $scope.bol2=!($scope.bol);
    }*/
    $scope.itemsArr = classifyService.getClassifyItems();
    console.log(classifyService.getClassifyItems())
      // console.log(classifyService.getClassifyItems())  
    $scope.toggle = function(){
       return $scope.butShow = ($scope.itemsArr[0]!=null) ? true:false;
    }
        // console.log($scope.itemsArr)
        $scope.countAll = function(){
            $scope.total=0;
        for(var i=0;i<$scope.itemsArr.length;i++){
            $scope.total +=  parseInt($scope.itemsArr[i].cnt);
        }
          return $scope.total;
      // console.log($scope.total);
        }

        $scope.moneyAll = function(){
            $scope.moneyTotal = 0;
            for(var i=0;i<$scope.itemsArr.length;i++){
            $scope.moneyTotal +=  Number($scope.itemsArr[i].cnt)*Number($scope.itemsArr[i].price);

            }
            return  $scope.moneyTotal.toFixed(2);
        }

    
}])
.config(function($stateProvider,$urlRouterProvider){
    $stateProvider.state("myOrder",{
        url:"/myOrder",
        templateUrl:"./view/second/mine_order.html"
    })
        $urlRouterProvider.when("","home")
})
